﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Vertica.Data.VerticaClient;

namespace VerticaApp
{
    public partial class VerticaBrowser : Form
    {
        VerticaConnectionStringBuilder builder = new VerticaConnectionStringBuilder();

        public VerticaBrowser()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void Connect_Click(object sender, EventArgs e)
        {
            string hostname = hostNameBox.Text;
            string port = portTextBox.Text;
            builder.Host = hostname;
            builder.Port = Convert.ToInt16(port);
            builder.Database = "test";
            builder.User = "dbadmin";
            builder.Password = "test";
            VerticaConnection _conn = new VerticaConnection(builder.ToString());
            _conn.Open();
            Connect.Text = _conn.ServerVersion;

            DataTable table = _conn.GetSchema("Tables", new string[] { null, null, null, "SYSTEM TABLE" });
            StringBuilder sb = new StringBuilder();
            foreach (DataRow row in table.Rows)
            {
                foreach (DataColumn col in table.Columns)
                {                                
                    sb.Append(String.Format("{0} = {1}", col.ColumnName, row[col]));
                }
                sb.Append("============================\n");
            }
            richTextBox1.Text = sb.ToString();
        }
    }
}
